﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HotelMatchUtility.Entity;
using HotelMatchUtility.Utility;

namespace HotelMatchUtility.Comparer
{
    public class Impl_SimGeoAddressComparer : HotelCompareBase, ICompareCondition
    {
        private double kiloMeter;

        private double nameLikePercent;

        public Impl_SimGeoAddressComparer(double kiloMeter, double nameLikePercent)
        {
            this.kiloMeter = kiloMeter;
            this.nameLikePercent = nameLikePercent;
            ConditionName = string.Format("【相似】[距离小于{0}km]且[地址近似大于{1}]"
                , Math.Round(kiloMeter, 3), nameLikePercent.ToString("p"));
            IsExactCondition = false;
            IsExclusiveCondition = false;
            TargetIsContinue = false;
        }

        public override bool DoCompare(HotelEntity hotelTarget, HotelEntity hotelToCompare)
        {
            double kiloMeterResult = hotelTarget.LonLatToKilometer(hotelToCompare);
            return (kiloMeterResult < kiloMeter)
                && CommonUtility.CompareTwoStringSimilary(hotelTarget.GetFormatAddress(), hotelToCompare.GetFormatAddress(), nameLikePercent);
        }
    }
}
